package scalaLearning.part1.works

object Test2 {
  def main(args: Array[String]): Unit = {
    //遍历字符串
    val str = "hello"
    for (i <- str) println(i)
    for (i <- 0 until str.length) println(str.charAt(i))
    //遍历数组
    val arr2: Array[Int] = Array(1, 2, 3, 4, 5)
    for (j <- arr2) println(j)
    for (j <- 0 until arr2.length) println(arr2(j))
    //现有数组数组Array(1,2,3,4,5,6)，用两种方法完成对数组中的每个数乘以10，生成一个新数组
    val arr = Array(1, 2, 3, 4, 5, 6)
    for (i <- arr) yield i * 10
    //更简单的方法：
    arr.map(_ * 10)
    arr.map(x => x * 10)
    //现有数组Array(1,2,3,4,5,6)，把数组中的偶数取出来乘以100得到一个新数组


  }
}
